package com.njtoyo.taxi.admin.rest.controller.business.driver;

import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.mapper.master.entity.DriverNotifyMessage;
import com.njtoyo.taxi.admin.rest.wrapper.business.driver.notifyMessage.CreateWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.driver.notifyMessage.ListWrapper;
import com.njtoyo.taxi.admin.service.business.driver.NotifyMessageService;
import com.njtoyo.taxi.entity.backend.AdminUser;
import com.taxi.entity.common.RestResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/business/driver/notify_message")
@Api(tags = "司机通知消息")
public class NotifyMessageController {

    @Autowired
    private NotifyMessageService noticeMessageService;

    @GetMapping("")
    @ApiOperation(value = "获取司机通知消息列表", notes = "权限: driver_notify_message")
    @PermissionScope(names = {"driver_notify_message"})
    public RestResult getList(@ModelAttribute("admin") AdminUser adminUser, @Valid ListWrapper listWrapper) {
        return noticeMessageService.getList(adminUser, listWrapper);
    }

    @PostMapping("")
    @ApiOperation(value = "创建司机通知消息", notes = "权限: driver_notify_message_create")
    @PermissionScope(names = {"driver_notify_message_create"})
    public RestResult create(@Valid @RequestBody CreateWrapper createWrapper) {
        return noticeMessageService.create(createWrapper);
    }

    @PatchMapping("/{id}")
    @ApiOperation(value = "修改司机通知消息", notes = "权限: driver_notify_message_update")
    @PermissionScope(names = {"driver_notify_message_update"})
    public RestResult update(@PathVariable("id") Long id, @RequestBody DriverNotifyMessage updateNotifyMessage) {
        return noticeMessageService.update(id, updateNotifyMessage);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除司机通知消息", notes = "权限: driver_notify_message_delete")
    @PermissionScope(names = {"driver_notify_message_delete"})
    public RestResult delete(@PathVariable("id") Long id) {
        return noticeMessageService.delete(id);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取司机通知消息详情", notes = "权限: driver_notify_message")
    @PermissionScope(names = {"driver_notify_message"})
    public RestResult getDetail(@PathVariable("id") Long id) {
        return noticeMessageService.getDetail(id);
    }
}
